package com.oj.grap;

import java.util.Arrays;
import java.util.Scanner;

public class DijskraAlg {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNext()) {
            int numNode = scanner.nextInt();
            int numEdge = scanner.nextInt();
            int[][] graph = new int[numNode][numNode];
            for (int i = 0; i < numNode; i++) {
                Arrays.fill(graph[i], MAX_DIS);
            }
            for (int i = 0; i < numEdge; i++) {
                int start = scanner.nextInt();
                int end = scanner.nextInt();
                int weight = scanner.nextInt();
                graph[start][end] = weight;
                graph[end][start] = weight;
            }

        }
    }

    /**
     * 表示点之间不可达
     */
    private static final int MAX_DIS = 1000001;

    private static int[] dfs(int[][] graph, int start) {
        int numNode = graph.length;
        int[] shortest = new int[numNode];
        boolean[] visited = new boolean[numNode];
        visited[start] = true;
        for (int i = 0; i < numNode; i++) {
            int min = MAX_DIS;
            int ind = -1;
            for (int j = 0; j < numNode; j++) {
                if(visited[i]) {
                   continue;
                }
                if(graph[start][j] < min) {
                    min = graph[start][j];
                    ind = j;
                }
            }
            visited[ind] = true;
            shortest[ind] = min;
            for (int j = 0; j < numNode; j++) {
                if(!visited[j]) {
//                    graph[start][j]
                }
            }
        }
        return shortest;
    }

}
